<?php

class ContentsController extends AppController {

  public $helpers = array('Html', 'TWSForm');
  public $components = array('Session', 'Util');
  public $name = 'Contents';
  public $map = array();

  //TODO - Keywords and description have to be filled out

  function __construct($request=null, $response=null) {
    parent::__construct($request, $response);
    $this->map = Configure::read('App.contentPage');
  }

 function message(){}

  function home() {
    $this->loadModel('HomepagePhoto');
    $this->layout='custom';
    $photos = $this->HomepagePhoto->find("all", array("order" => array("HomepagePhoto.created" => 'desc')));
    $this->set("title_for_layout", "Destination Weddings in Trinidad and Tobago and the Caribbean Destination Weddings at Isle Vow");
    $this->set("meta_keywords", "Isle Vow weddings Trinidad Tobago destination wedding planning caribbean weddings getting married in trinidad and tobago organizers photographers caterers wedding services");
    $this->set("meta_description", "Isle Vow provides services for Caribbean weddings and destination weddings in Trinidad and Tobago.");
    $this->set('photos', $photos);
  }

  function contact() {
    $this->set("title_for_layout", "Contact Isle Vow for Destination Weddings in Trinidad and Tobago.");
    $this->set("meta_keywords", "Isle Vow Destination Weddings Caribbean Weddings Trinidad and Tobago contact information");
    $this->set("meta_description", "Contact Isle Vow in Trinidad and Tobago for caribbean wedding and destination wedding planning and services");
  }

  function about_us() {
    $this->set("title_for_layout", "About Isle Vow Trinidad and Tobago Weddings and Destination Weddings in the Caribbean");
    $this->set("meta_keywords", "Isle Vow About Destination Caribbean Weddings Trinidad Tobago Services Wedding planning");
    $this->set("meta_description", "Learn about the Isle Vow and the goal of our company for wedding planning and services in Trinidad and Tobago and the Caribbean.");
    $this->Content->id = $this->map['aboutus'];
    $result = $this->Content->read();
    $this->set('contents', $result);
    $this->render('about_us');
  }

  function catalog() {
    $this->set("title_for_layout", "Isle Vow Services and Products Catalog");
    $this->set("meta_keywords", "Isle Vow Catalog Products Services Party Favours");
    $this->set("meta_description", "View the Isle Vow Catalog for information on products which we offer to make your wedding a success.");
    $this->Content->id = $this->map['catalog'];
    $result = $this->Content->read();
    $this->set('contents', $result);
    $this->render('catalog');
  }

  function tourism() {
    $this->set("title_for_layout", "Destination Weddings information provided by Isle Vow for Trinidad and Tobago and the Caribbean");
    $this->set("meta_keywords", "Trinidad and Tobago Destination Weddings");
    $this->set("meta_description", "Destination Weddings information in Trinidad and Tobago for visitors to the beautiful twin island paradise.");
    $this->Content->id = $this->map['tourism'];
    $result = $this->Content->read();
    $this->set('contents', $result);
    $this->render('tourism');
  }

  function legal(){
    $this->set("title_for_layout", "Legal information for Isle Vow");
    $this->set("meta_keywords", "Legal Isle Vow Trinidad and Tobago Destination Weddings");
    $this->set("meta_description", "Legal information and terms of use for Isle Vow.");
    $this->Content->id = $this->map['legal'];
    $result = $this->Content->read();
    $this->set('contents', $result);
    $this->render('legal');
  }


  function concierge_services() {
    $this->layout ="custom";
    $this->set("title_for_layout", "Isle Vow Concierge Services");
    $this->set("meta_keywords", "Isle Vow Concierge Services Wedding Honeymoon Trinidad Tobago");
    $this->set("meta_description", "Learn about Concierge Wedding and Honeymoon services that are offered by Isle Vow in Trinidad and Tobago.");
    $this->render('concierge_services');
  }

  function admin_home() {
    $this->layout = 'admin';
    $this->set('title_for_layout', 'Isle Vow Administrative Home Page');
  }

  function admin_index() {
    //Display a list of content pages
    $this->layout = 'admin';
    $this->set('options', $this->Content->find('list', array('fields' => array('Content.id', 'Content.content_description'), 'order' => array('Content.content_description' => 'asc'))));
  }

  function admin_view() {
    $this->layout = 'admin';
    $id = $this->request->data["id"];
    if (!empty($id)) {
      $this->redirect(array('action' => 'edit', 'admin' => true, $id));
    }
  }

  function admin_edit($id = null) {
    $this->layout = 'admin';
    $this->Content->id = $id;
    if ($this->request->is('get')) {
      $this->set('contents', $this->Content->read());
    } else {
      $this->_processAction($this->request, 'edit', $id);
    }
  }

    function photographer_home() {
    $this->layout = 'photographer';
    $this->set('title_for_layout', 'Isle Vow Photographer Home Page');
  }

  function member_home() {
    $this->layout = 'member';
    $this->set('title_for_layout', 'Isle Vow Member Home Page');
  }

  private function _processAction($dataIn, $action='add', $id=null) {
    $data = $this->_processRequestData($dataIn);
    $data['Content']['id'] = $id;
    $this->Content->set($data);
    if ($this->Content->validates()) {
      if ($this->Content->save($data, false)) {
        $this->Session->setFlash('The record was successfully updated.');
        $this->redirect(array('action' => 'index'));
      }
    }
  }

}

?>
